package cn.gson.fengboot.model.service;

import cn.gson.fengboot.model.dao.ZinvoiceDao;
import cn.gson.fengboot.model.dao.ZreturnedmoneylogDao;
import cn.gson.fengboot.model.mapper.ZinvoiceMapper;
import cn.gson.fengboot.model.pojos.Zinvoice;
import cn.gson.fengboot.model.pojos.Zreturnedmoneylog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class ZinvoiceService {
    @Autowired
    ZinvoiceMapper fpmapper;

    @Autowired
    ZinvoiceDao fpdao;

    @Autowired
    ZreturnedmoneylogDao hkdao;

    /*
        发票页面查询方法
     */
    public List<Zinvoice> kaipiao(String search,String search2){
        return fpmapper.kaipiao(search,search2);
    }

    /*
        订单详情发票查询
     */
    public List<Zinvoice> kaipiaodd(String search){
        return fpmapper.kaipiaodd(search);
    }

    /*
        退货单详情发票查询
    */
    public List<Zinvoice> kaipiaothd(String search){
        return fpmapper.kaipiaothd(search);
    }

    /*
        回款计划详情发票查询
    */
    public List<Zinvoice> kaipiaohk(String search){
        return fpmapper.kaipiaohk(search);
    }

    /*
    发票页面新增方法
    */
    public void addfapiao(Zinvoice fp){
        fpdao.save(fp);


        Zreturnedmoneylog zreturnedmoney = hkdao.findById(fp.getReturnedmoneylogId().getReturnedmoneylogId()).get();
        zreturnedmoney.setReturnedmoneylogInvoice("已开发票");
        hkdao.save(zreturnedmoney);
    }

    //<!--谭方圆=>客户合并的交付记录查询-->
    public List<Zinvoice> tfyfapiao(Integer id1, Integer id2){
        return fpmapper.tfyfapiao(id1,id2);
    }
}
